﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using KKSGameLibrary.Logic;

namespace KaKaSongGame
{
	public partial class PlayerPin : UserControl
	{
		public PlayerPin()
		{
			
			// Required to initialize variables
			InitializeComponent();
		}



		public Color PuppetColor
		{
			get { return (Color)GetValue(PuppetColorProperty); }
			set { SetValue(PuppetColorProperty, value); }
		}

		public static readonly DependencyProperty PuppetColorProperty =
			DependencyProperty.Register("PuppetColor", typeof(Color), typeof(PlayerPin),
			new PropertyMetadata(
				new PropertyChangedCallback((s, e) =>
					{
						((PlayerPin)s).path.Fill = new SolidColorBrush((Color)e.NewValue);
					})));

		

		public OpenDirection Position
		{
			get { return (OpenDirection)GetValue(PositionProperty); }
			set { SetValue(PositionProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Position.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty PositionProperty =
			DependencyProperty.Register("Position", typeof(OpenDirection), typeof(PlayerPin),
			new PropertyMetadata(
				new PropertyChangedCallback((o, e) =>
					{
						var ppin = o as PlayerPin;
						var dir =(OpenDirection) e.NewValue;
						switch (dir)
						{
							case OpenDirection.Center:
								ppin.VerticalAlignment = VerticalAlignment.Center;
								ppin.HorizontalAlignment = HorizontalAlignment.Center;
								break;
							case OpenDirection.Left:
								ppin.VerticalAlignment = VerticalAlignment.Center;
								ppin.HorizontalAlignment = HorizontalAlignment.Left;
								break;
							case OpenDirection.Top:
								ppin.VerticalAlignment = VerticalAlignment.Top;
								ppin.HorizontalAlignment = HorizontalAlignment.Center;
								break;
							case OpenDirection.Right:
								ppin.VerticalAlignment = VerticalAlignment.Center;
								ppin.HorizontalAlignment = HorizontalAlignment.Right;
								break;
							case OpenDirection.Bottom:
								ppin.VerticalAlignment = VerticalAlignment.Bottom;
								ppin.HorizontalAlignment = HorizontalAlignment.Center;
								break;
							default:
								break;
						}
					})));
		
	}
}